<?
	error_reporting(E_ALL ^ E_NOTICE);
	cria_variaveis($_POST,$_GET,$_FILES); 
?>
<p class=titulo align=center><?php echo $msg->get('NEWTON_MSG_02') ?></p>
<p class=subtitulo align=center><?php echo $msg->get('NEWTON_MSG_03') ?></p>
<p>
<div class="tabbar">
    <ul>
    <li><a href="index.php?inc=newton.php&modo=material"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "material") echo " class=\"tabact\""; ?>><?php echo $msg->get('Material_Teorico') ?></a></li>
    <li><a href="index.php?inc=newton.php&modo=exemplo"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo") echo " class=\"tabact\""; ?>><?php echo $msg->get('Exemplos_Prontos') ?></a></li>
    <li><a href="index.php?inc=newton.php&modo=teclado"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "teclado") echo " class=\"tabact\""; ?>><?php echo $msg->get('Entrada_Teclado') ?></a></li>
    </ul>
</div>
<div id="cas">
<?php
if (!isset($Calcular)) {
    if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "material")
    {
        require_once("./classes/upload.php");
        $uploads = new Upload();
        $uploads->Lista("interpolacao");
    }
    else if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo" && !isset($opcao_execucao)) { //leitura de dados via banco de dados - modulo de exemplos e exercicios
        include "exibe_prob_newton_xml.php";
	}
	else if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "teclado" || isset($opcao_execucao)) {
	   if(strlen($opcao_execucao) == 0) {
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<br>";
		echo "".$msg->get('NEWTON_MSG_04')."<br><br>";
		echo "<input type=radio name=opcao_execucao value=0>".$msg->get('NEWTON_MSG_05')."<br>"; // 0 para caso discreto, 1 para caso continuo 
		echo "<input type=radio name=opcao_execucao value=1>".$msg->get('NEWTON_MSG_06')."<br><br>";
		echo "<input type=hidden name=executar value=sim>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_02').">";
		echo "</form>"; 
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_03').">";
		echo "</form>";
	   }
	   else if ((!isset($n) && !isset($funcao) && !isset($a) && !isset($b)) || !checaNumerico($n) || ($opcao_execucao == 1 && (!checaNumerico($a) || !checaNumerico($b))))
       {
        if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo")
            verificaBib($xml_file);
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<br>";
		echo "".$msg->get('NEWTON_MSG_07')."<br>";
		echo "<input type=text size=3 maxlength=5 name=n><br><br>";
		if ($opcao_execucao==1) {
		   echo "<a href=javascript:winopen('ajuda/funcoesphp.php')>".$msg->get('G_MSG_29')."</a>";	
		   echo "<p>";
		   echo "".$msg->get('NEWTON_MSG_09')."<br>";
		   echo "f(x)= <input type=text size=60 maxlength=100 name=funcao value=\"".$funcao."\"><br>";
		   echo "<br>";
		   echo "".$msg->get('NEWTON_MSG_10')."<br>";
		   echo "[<input type=text size=5 maxlength=5 name=a>,<input type=text size=5 maxlength=5 name=b>]";
		   echo "<br><br>";
		}// end if
		echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
		echo "<input type=hidden name=executar value=sim>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_02').">";
		echo "</form>"; 
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_03').">";
		echo "</form>";
	   }
	   else if ( ($opcao_execucao==1) and (strlen($distribuicao)==0) ) {
        if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo")
            verificaBib($xml_file);
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<br>";
		echo "".$msg->get('NEWTON_MSG_11')."".($n)."".$msg->get('NEWTON_MSG_12')." [&nbsp<input type=text size='4' maxlength='5' name=a value=".($a).">&nbsp,";
		echo "&nbsp<input type=text size='4' maxlength='5' name=b value=".($b).">&nbsp] :";
		echo "<input type=hidden size='4' maxlength='5' name=n value=".($n).">";
		echo "<br> <br>";
		echo "<input type=radio name=distribuicao value=1 unchecked> ".$msg->get('NEWTON_MSG_13')." <br>";
		echo "<input type=radio name=distribuicao value=2 unchecked> ".$msg->get('NEWTON_MSG_14')." <a href=\"javascript:void(0)\" onClick=\"window.open('info.php?topico=chebyshev', 'Informacoes', 'toolbar=no, location=no, directories=no, scrollbars=yes,resizable=yes,menubar=no,width=400,height=300')\"><img src=\"imagens/info.gif\" border=\"0\"></a><br>";
		echo "<br>";
		echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
		echo "<input type=hidden name=n value=".($n).">";
		echo "<input type=hidden name=funcao value=\"".($funcao)."\">";
		echo "<input type=hidden name=a value=".($a).">";
		echo "<input type=hidden name=b value=".($b).">";
		echo "<input type=hidden name=executar value=sim>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_02').">";
		echo "</form>"; 
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_03').">";
		echo "</form>";
	   }
	   else { // Pagina final, para a entrada dos valores de x e y que necessitem ser digitados
        if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo")
            verificaBib($xml_file);
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
		echo "<input type=hidden name=distribuicao value=".($distribuicao).">";
		echo "<input type=hidden name=funcao value=\"".($funcao)."\">";
		echo $msg->get('NEWTON_MSG_15');
		echo "<input type=text size='4' maxlength='5' name=n value=".($n)." readonly>";
		echo "<br> <br>";
		$grau = $n-1;
		$ne=3*$grau;
		echo "".$msg->get('NEWTON_MSG_16')." <b> </b> <input type=text size='4' maxlength='5' name=grau value=".($grau).">";
		if ($opcao_execucao ==1) {
			   echo "<br><br>".$msg->get('NEWTON_MSG_17')."<br>";
			   echo "f(x)= ".$funcao;
			}	   
		if ( ($opcao_execucao == 1) && ($distribuicao==1) ) { // distribuicao uniforme 
		   echo "<br> <br>";
		   //echo "".(NEWTON_MSG_18)." [&nbsp<input type=text size='4' maxlength='5' name=a value=".($a).">&nbsp,";
		   //echo "&nbsp<input type=text size='4' maxlength='5' name=b value=".($b).">&nbsp] :";
           echo $msg->get('NEWTON_MSG_18')." [ $a , $b ]:";
           echo "<input type=hidden name=a value=$a>";
           echo "<input type=hidden name=b value=$b>";
		   $fracao = ($b - $a) / ($n - 1);
		   eval ('$X[0]=$a;$x=$X[0];$Y[0]='.normaliza_funcao($funcao).';');
		   for ($i = 1; $i < $n; $i++) {
			  eval ('$X[$i]=$X[$i-1]+$fracao;$x=$X[$i];$Y[$i]='.normaliza_funcao($funcao).';');
		   } // end for
		} // end if
		else if ( ($opcao_execucao == 1) && ($distribuicao==2) ) { // distribuicao de chebyshev
		   echo "<br> <br>";
		   //echo "".(NEWTON_MSG_18)." [&nbsp<input type=text size='4' maxlength='5' name=a value=".($a).">&nbsp,";
		   //echo "&nbsp<input type=text size='4' maxlength='5' name=b value=".($b).">&nbsp] :";
           echo $msg->get('NEWTON_MSG_18')." [ $a , $b ]:";
           echo "<input type=hidden name=a value=$a>";
           echo "<input type=hidden name=b value=$b>";
 		   echo "<br><br>".$msg->get('LAGRANGE_MSG_24')."<br><br>";
   		   echo G_FORMULA_CHEBYSHEV."";
		   for ($i = 0; $i < $n; $i++) {
			  $X[$i] = ( ($a + $b)/2 ) +( ($a - $b)/2 ) * cos (((2*($i+1)-1) / (2*$n) ) * M_PI);
			  eval ('$x=$X[$i];$Y[$i]='.normaliza_funcao($funcao).';');
		   } // end for
		   for ($tam=$n; $tam>1; $tam--){ //ordena�o do vetor
			  for ($i=0; $i<$tam-1; $i++) {
				  if ( $X[$i] > $X[$i+1] ) {
					 $aux = $X[$i];
					 $X[$i] = $X[$i+1];
					 $X[$i+1] = $aux;
					 $aux = $Y[$i];
					 $Y[$i] = $Y[$i+1];
					 $Y[$i+1] = $aux;
				  } //end if
			  } //end for j
		   } // end for i
		} // end else
		echo "<br><br>".$msg->get('NEWTON_MSG_19')."<br>";
		echo "<br>";
		for ($i=0; $i<$n; $i++) {
			echo "x".$i." = <input type=text size='6' maxlength='30' name=X[".($i)."] value=".($X[$i]).">";
			echo " y".$i." = <input type=text size='6' maxlength='30' name=Y[".($i)."] value=".($Y[$i])."><br>";
		} //for
		echo "<br>";
		echo "".$msg->get('NEWTON_MSG_20')."<input type=text size='6' maxlength='8' name=valor value=".($valor).">";
		echo "<p><p>";
		echo "<p>";
		if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
		{
			echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
			echo "<input type=\"hidden\" name=\"indice\" value=\"$indice\">";
			echo "<input type=\"hidden\" name=\"navegacao\" value=\"sim\">";
		}
		echo "<input class=button type=submit name=Calcular value=".$msg->get('G_MSG_04').">";
		echo "<br>";
		echo "</form>";
        echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
		echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_03').">";
		echo "</form>";
		if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
		{
			echo "<form name=\"exemplos\" enctype=\"multipart/form-data\" method=\"post\">";
			echo "<script language=\"javascript\" type=\"text/javascript\">\n";
			echo "function criarLinks(value) {\n";
			echo "document.exemplos.indice.value = value;\n";
			echo "document.exemplos.action = 'index.php?inc=newton.php&modo=exemplo'\n";
			echo "document.exemplos.submit();\n";
			echo "}\n";
			echo "</script>";
			echo "<input type=\"hidden\" name=\"id_bib\" value=\"".$id_bib."\">";
			echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
			echo "<input type=\"hidden\" name=\"indice\">";
			echo "</form>";
			echo $msg->get('Outros_Exemplos')."<br>";
            $objeto = new DomDocument();
            $objeto->load($xml_file);
        	//$raiz = $objeto->document_element();
        	$filho = $objeto->getelementsbytagname("interpolation");
        	if ($filho->length > 0)
        	{
        		$interpol = $filho->item(0)->getelementsbytagname("interpol");
        		for ($i=0; $i<$interpol->length; $i++)
        		{
        			if ($i != 0) echo " | ";
        			if ($i == $indice) echo "<b>";
        			echo "<a href=\"javascript:criarLinks($i);\"><u>".($i+1)."</u></a>";
        			if ($i == $indice) echo "</b>";
        	
        		  }
            }
          }
           } //end if
	   echo "</body>";
	}
} else {
    if (!checaNumerico($X) || !checaNumerico($Y) || !checaNumerico($valor))
    {
?>
        <p><font color="red"><?php echo $msg->get('Apenas_Dados_Numericos') ?></font></p>
        <p><input type="button" value="<?php echo $msg->get('Voltar') ?>" onclick="history.back()" class="button"></p>
<?php
    }
    else
    {
        for ($tam=$n; $tam>1; $tam--){
            for ($i=0; $i<$tam-1; $i++) {
                if ( $X[$i] > $X[$i+1] ) {
                    $aux = $X[$i];
                    $X[$i] = $X[$i+1];
                    $X[$i+1] = $aux;
                    $aux = $Y[$i];
                    $Y[$i] = $Y[$i+1];
                    $Y[$i+1] = $aux;
                }
            }
        }
        if (($valor<$X[0])or($valor>$X[$n-1])) {
            echo "<br>";
            echo "".$msg->get('SPLINE_MSG_24')."".($valor)."".$msg->get('SPLINE_MSG_25')."[".($X[0]).",".($X[$n-1])."].";
            echo "<form method=post enctype=multipart/form-data action=index.php?inc=lagrange.php>";
            echo "<input type=hidden name=n value=".($n).">";
            echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
            echo "<input type=hidden name=executar value=sim>";
            for ($i=0; $i<$n; $i++) {
                echo "<input type=hidden name=X[".($i)."] value=".($X[$i]).">";
                echo "<input type=hidden name=Y[".($i)."] value=".($Y[$i]).">";
            } // end for
            echo "<p>";
            echo "<input class=button type=submit name=Submit value=".$msg->get('SPLINE_MSG_26').">";
            echo "<input type=hidden name=distribuicao value=".$distribuicao.">";
            echo "<input type=hidden name=funcao value=\"".$funcao."\">";
            echo "<input type=hidden name=a value=".$a.">";
            echo "<input type=hidden name=b value=".$b.">";
            echo "</form>";
        } else {
            $ne=3*$grau;
            if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo")
                verificaBib($xml_file);
            echo $msg->get('NEWTON_MSG_19');
            echo "<br><br><table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\"><tr><td align=\"center\" bgcolor=\"#ffffff\">".$msg->get("Indice")."</td><td align=\"center\" width=\"60\" bgcolor=\"#ffffff\">x</td><td align=\"center\" width=\"60\" bgcolor=\"#ffffff\">y</td></tr>";
            for ($i=0; $i<$n; $i++) {
            echo "<tr>";
                //echo "x".$i." = <input type=text size='6' maxlength='30' name=X[".($i)."] value=".($X[$i]).">";
            echo "<td align=\"center\" bgcolor=\"#ffffff\">$i</td><td align=\"center\" bgcolor=\"#ffffff\">".round($X[$i],4)."</td><td align=\"center\" bgcolor=\"#ffffff\">".round($Y[$i],4)."</td>";
            echo "</tr>";
                //echo " y".$i." = <input type=text size='6' maxlength='30' name=Y[".($i)."] value=".($Y[$i])."><br>";
            } //for
        echo "</table>";
            echo "<br>";
            echo "".$msg->get('NEWTON_MSG_20')."<input type=text size='6' maxlength='8' name=$valor value=".($valor).">";
            echo "<br><br>";
            $k = 0;
            echo "<b> ".$msg->get('NEWTON_MSG_25')." ".$k."</b>";
            echo "<br><br>";
            /****diferencas divididas ***/
            for($i=0;$i<=$n-1;$i++) {
            $tabela[$i][-1]= $X[$i];
            $tabela[$i][0]= $Y[$i];
            echo "&#8710 <sup>0</sup> y<sub>".($i)."</sub> = f[x<sub>".($i)."</sub>]<br>";
            echo "<font color=white> &#8710 <sup>0</sup> y<sub>".($i)."</sub> </font> = f(".$X[$i].") = <font color=blue>".$Y[$i]."</font><br>";
            }
            for($k=1;$k<=$n-1;$k++){
            echo "<br>";
            echo "<b> ".$msg->get('NEWTON_MSG_25')." ".$k."</b>";
            echo "<br><br>";
            for($i=$k;$i<=$n-1;$i++){
                $tabela[$i-$k][$k]=($tabela[$i-$k+1][$k-1]-$tabela[$i-$k][$k-1])/
                ($tabela[$i][-1]-$tabela[$i-$k][-1]);
                    echo "&#8710 <sup>".$k."</sup> y<sub>".($i-$k)."</sub> = f[";
                for ($j=$i-$k; $j<$i; $j++)
                    echo "x<sub>".($j)."</sub>,";
                echo "x<sub>".($i)."</sub>";
                echo "] = (&#8710 <sup>".($k-1)."</sup> y<sub>".($i-$k+1)."</sub> - &#8710 <sup>".($k-1)."</sup> y<sub>".($i-$k)."</sub>) / (x<sub>".($i)."</sub> - x<sub>".($i-$k)."</sub>) <br>";
                    echo "<font color=white>";
                echo "&#8710 <sup>".$k."</sup> y<sub>".($i)."</sub> = f[";
                for ($j=$i-$k; $j<$i; $j++)
                    echo "x<sub>".($j)."</sub>,";
                echo "x<sub>".($i)."</sub>] ";
                echo "</font>";
                echo "= (".$tabela[$i-$k+1][$k-1]." - ".$tabela[$i-$k][$k-1].") / (".$tabela[$i][-1]." - ".$tabela[$i-$k][-1].") = <font color=blue> ".$tabela[$i-$k][$k]." </font> <br>";
            }
            }
            echo "<br><br>";
            echo $msg->get('NEWTON_MSG_24');
            echo "<br>";
            echo "<table>";
            echo "<tr>";
            for($k=-1;$k<=$n;$k++){
            echo "<td align=center>";
            if ($k==-1) {
                echo "i";
            } else if ($k==0) {
                echo "x<sub>i</sub>";
            } else if ($k==1) {
                echo "y<sub>i</sub>";
            } else {
                echo "&#8710 <sup>".($k-1)."</sup> y<sub>i</sub>";
            }
            echo "</td>";
            } // end for k
            echo "</tr>";
            for ($i=0; $i<$n; $i++) {
            echo "<tr>";
            echo "<td>";
            echo "<input type=text size='8' maxlength='10' name=pontos value=".($i).">";
            echo "</td>";
            for($k=-1;$k<=$n-1;$k++){
                echo "<td>";
                echo "<input type=text size='8' maxlength='10' name=tabela[".($i)."][".($k)."] value=".(@$tabela[$i][$k]).">";
                echo "</td>";
            } // end for k
            echo "</tr>";
            } // end for i
                echo "</table>";
            echo "<br>";
            echo "<b> ".$msg->get('NEWTON_MSG_26')." </b> <br><br>";
            echo "<font size=3>";
            echo "p(x) = y<sub>0</sub> + <font color=red> &#8721 ( <font color= green> &#8710 <sup>i</sup>  y<sub>0</sub> </font> </font> * <font color=blue> &#8719 (x - x<sub>j</sub>) </font> <font color=red> ) </font> ".$msg->get('Onde')." i &#1108 [1,n] , j &#1108 [0,i - 1]";
            echo "</font>";
            echo "<br><br>";
            echo $msg->get('NEWTON_MSG_27').$valor.$msg->get('NEWTON_MSG_28');
            echo "<br><br>";
            echo "<table border=1 CELLSPACING=0 CELLPADDING=2>";
            echo "<tr>";
            echo "<td align = center width=40>";
            echo "i";
            echo "</td>";
            echo "<td align = center>";
            echo "&#8719 (x - x<sub>j</sub>)";
            echo "</td>";
            echo "<td align = center>";
            echo "&#8710 <sup>i</sup>  y<sub>0</sub>";
            echo "</td>";
            echo "<td align=center>";
            echo "&#8721 ( &#8710 <sup>i</sup>  y<sub>0</sub> * &#8719 (x - x<sub>j</sub>) )";
            echo "</td>";
            echo "<td align=center>";
            echo $msg->get('NEWTON_MSG_29');
            echo "</td>";
            echo "</tr>";
            /******* Interpolacao do ponto w  ******/
            $p=0;
            for($i=0;$i<=$n-1;$i++){
            echo "<tr>";
            echo "<td align = center>".$i."</td>";
            $l=1;
            echo "<td>";
            echo "<font color=blue>";
            for($t=$i;$t>0;$t--){
                $l*= $valor-$X[$t-1];
                if ($X[$t-1] >= 0) {
                    $string.='($x-'.($X[$t-1]).")*";
                    echo "(x - ".$X[$t-1].") ";
                } else {
                    $string.='($x+'.(abs($X[$t-1])).")*";
                    echo "(x + ".(abs($X[$t-1])).") ";
                    }
            }
            $string.="(".($tabela[0][$i]).")+";
            if ($i==0)
                echo "<font color=black> - </font>";
            else
                echo " = ".$l." </font>";
            echo "</td>";
                echo "<td>";
            echo "<font color=green>";
            if ($i==0)
                echo "<font color=black> - </font>";
            else
                echo $tabela[0][$i];
            echo "<font>";
            echo "</td>";
            echo "<td>";
            echo "<font color=red>";
            if ($i==0)
                echo "<font color=black> - </font>";
            else
                echo $tabela[0][$i]*$l;
            echo "</font>";
            echo "</td>";
            $p+=$tabela[0][$i]*$l;
            echo "<td>";
            echo $p;
            echo "</td>";
            echo "<tr>";
            }
            echo "</table>";
            $string.='0';
            // para gerar o gr�ico dos pontos
            @$dados_grafico .= "Newton|";
            $dados_grafico .= "$string|";
            $dados_grafico .= "".($n+1)."|";
            for ($i=0;$i<$n;$i++)  $dados_grafico .= "$X[$i]|";
            $dados_grafico .= "$valor|";
            for ($i=0;$i<$n;$i++)  $dados_grafico .= "$Y[$i]|";
            $dados_grafico .= "$p|";
            $dados_grafico .= "$idioma|";
        if ($opcao_execucao == 1) $dados_grafico .= ":$funcao:|";
            $arquivo = gera_nome_arquivo();
        //	$arq = fopen ($arquivo, "w+");
        //	$escreve = fwrite($arq,$dados_grafico);
        //	fclose ($arq);
            $conn = &ADONewConnection($A_DB_TYPE);
            $conn->PConnect($A_DB_HOST,$A_DB_USER,$A_DB_PASS,$A_DB_DB);
            // $conn->debug=1;
            $sql = "INSERT INTO grafico(id,dados) values ('".$arquivo."','".$dados_grafico."');";
            $rs = $conn->Execute($sql);
            if ($rs === false) die(A_LANG_LOGIN_MSG5);
            $rs->Close();
            echo "<br><br>";
            echo "<b>".$msg->get('NEWTON_MSG_22')."</b> <br>";
            echo "<font size=4>p</font>(".($valor).") = ".($p)."<p><p>";
            echo "<table>";
            echo "<tr>";
            echo "<td><img src=interpolacao_grafico.php?arquivo=".$arquivo."  border=0 align=left width=600 height= 400></td>";
            echo "</table>";
            echo "<br>";
            if (isset($correcao) && $correcao == "sim") {
            echo "<b>".$msg->get('NEWTON_MSG_23')."</b>";
            echo "<br>";
            echo "<font size=4>p</font>(".($valor).") = ".($resp)."";
            } // end if
            echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
        if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
        {
            echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
            echo "<input type=\"hidden\" name=\"indice\" value=\"$indice\">";
            echo "<input type=\"hidden\" name=\"navegacao\" value=\"sim\">";
        }
            echo "<input type=hidden name=n value=".($n).">";
            echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
            echo "<input type=hidden name=executar value=sim>";
            for ($i=0; $i<$n; $i++) {
                    echo "<input type=hidden name=X[".($i)."] value=".($X[$i]).">";
                    echo "<input type=hidden name=Y[".($i)."] value=".($Y[$i]).">";
            } // end for
            echo "<input class=button type=submit name=Submit value=".$msg->get('SPLINE_MSG_26').">";
            if (isset($distribuicao)) echo "<input type=hidden name=distribuicao value=".$distribuicao.">";
            if (isset($funcao)) echo "<input type=hidden name=funcao value=\"".$funcao."\">";
            if (isset($a)) echo "<input type=hidden name=a value=".$a.">";
            if (isset($b)) echo "<input type=hidden name=b value=".$b.">";
            echo "</form>";
                echo "<br><br>";
            echo $msg->get('G_PROXIMO_EXEMPLO');
                echo "<br><br>";
                // formul�io para efetuar o mesmo c�culo pelo m�odo de lagrange
            echo "<form method=post enctype=multipart/form-data action=index.php?inc=lagrange.php>";
        if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
        {
            echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
            echo "<input type=\"hidden\" name=\"indice\" value=\"$indice\">";
            echo "<input type=\"hidden\" name=\"navegacao\" value=\"sim\">";
        }
            echo "<input type=hidden name=n value=".($n).">";
            echo "<input type=hidden name=grau value=".($n-1).">";
            echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
            echo "<input type=hidden name=executar value=sim>";
            for ($i=0; $i<$n; $i++) {
                echo "<input type=hidden name=X[".($i)."] value=".($X[$i]).">";
                echo "<input type=hidden name=Y[".($i)."] value=".($Y[$i]).">";
            } // end for
            echo "<input class=button type=submit name=Calcular value='".$msg->get('LAGRANGE_MSG_03')."'>";
            if (isset($distribuicao)) echo "<input type=hidden name=distribuicao value=".$distribuicao.">";
            if (isset($funcao)) echo "<input type=hidden name=funcao value=\"".$funcao."\">";
            if (isset($a)) echo "<input type=hidden name=a value=".$a.">";
            if (isset($b)) echo "<input type=hidden name=b value=".$b.">";
            echo "<input type=hidden name=valor value=".$valor.">";
            echo "</form>";
                // formul�io para efetuar o mesmo c�culo pelo m�odo de splines
            echo "<form method=post enctype=multipart/form-data action=index.php?inc=spline.php>";
        if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
        {
            echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
            echo "<input type=\"hidden\" name=\"indice\" value=\"$indice\">";
            echo "<input type=\"hidden\" name=\"navegacao\" value=\"sim\">";
        }
            echo "<input type=hidden name=n value=".($n).">";
            echo "<input type=hidden name=opcao_execucao value=".($opcao_execucao).">";
            echo "<input type=hidden name=executar value=sim>";
            for ($i=0; $i<$n; $i++) {
                echo "<input type=hidden name=x[".($i)."] value=".($X[$i]).">";
                echo "<input type=hidden name=y[".($i)."] value=".($Y[$i]).">";
            } // end for
            echo "<input class=button type=submit name=Calcular value='".$msg->get('SPLINE_MSG_03')."'>";
            if (isset($distribuicao)) echo "<input type=hidden name=distribuicao value=".$distribuicao.">";
            if (isset($funcao)) echo "<input type=hidden name=funcao value=\"".$funcao."\">";
            if (isset($a)) echo "<input type=hidden name=a value=".$a.">";
            if (isset($b)) echo "<input type=hidden name=b value=".$b.">";
            echo "<input type=hidden name=valor value=".$valor.">";
                echo "</form>";
            echo "<p>";
            echo "<form method=post enctype=multipart/form-data action=index.php?inc=newton.php>";
            echo "<input class=button type=submit name=Submit value=".$msg->get('G_MSG_03').">";
            echo "</form>";
            if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
            {
                echo "<form name=\"exemplos\" enctype=\"multipart/form-data\" method=\"post\">";
                echo "<script language=\"javascript\" type=\"text/javascript\">\n";
                echo "function criarLinks(value) {\n";
                echo "document.exemplos.indice.value = value;\n";
                echo "document.exemplos.action = 'index.php?inc=newton.php&modo=exemplo'\n";
                echo "document.exemplos.submit();\n";
                echo "}\n";
                echo "</script>";
                echo "<input type=\"hidden\" name=\"id_bib\" value=\"".@$id_bib."\">";
                echo "<input type=\"hidden\" name=\"xml_file\" value=\"".@$xml_file."\">";
                echo "<input type=\"hidden\" name=\"indice\">";
                echo "</form>";
                echo $msg->get('Outros_Exemplos').":<br>";
                $objeto = new DomDocument();
                $objeto->load($xml_file);
                //$raiz = $objeto->document_element();
                $filho = $objeto->getelementsbytagname("interpolation");
                if ($filho->length > 0)
                {
                    $interpol = $filho->item(0)->getelementsbytagname("interpol");
                    for ($i=0; $i<$interpol->length; $i++)
                    {
                        if ($i != 0) echo " | ";
                        if ($i == $indice) echo "<b>";
                        echo "<a href=\"javascript:criarLinks($i);\"><u>".($i+1)."</u></a>";
                        if ($i == $indice) echo "</b>";
                    }
                }
            }
        }
    }
}
?>
</div>